var website = {
    vector: null,
    provinceSource: null,
    citySource: null,
    countySource: null,
    rqSource: null,
    rqInfoSource: null,
    selectPointerMove: null,
    inputData: null,
    rqInfoVector: null,
    clickFeature:null,
    clickStyle:null,
    mousePosition:null,
    isFindClick:false,
    rqInfoId:null,
    init: function () {
        map.on('pointermove', function (evt) {
            website.mousePosition = evt.coordinate;
        });
        var style = function (feature, resolution) {
            var type = feature.getGeometry().getType();
            var style = feature.getStyle();
            var text = null;
            if (typeof feature.getProperties().text === 'undefined') {
                text = 'none';
            } else {
                var text = feature.getProperties().text
            }
            feature.setStyle(website.getUnselectedPropertyStyle(type, text, style, feature));
        }
        this.vector = new ol.layer.Vector({
            source: this.getProvinceSource(),
            style: style
        });
        map.addLayer(this.vector);
        this.selectPointerMove = new ol.interaction.Select({
            condition: ol.events.condition.pointerMove
        });
        this.selectPointerMove.on('select', function (e) {
            website.onPointerMove(e);
        });
        map.addInteraction(this.selectPointerMove);
        map.on('singleclick', function (e) {
            website.onPointerClick(e);
        });
        map.getView().on('change:resolution', function (e) {
            website.onResChange(e);
        });
        this.reset();
    },
    getProvinceSource: function (id) {
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                var url = '../../assets/newMap/data/mapdata/province.json';
                $.getJSON(url, function (provinceData) {
                    var zoom = map.getView().getZoom();
                    var radius = 1e6 / Math.pow(2, zoom - 2);
                    var features = source.getFormat().readFeatures(provinceData);
                    $.ajax({
                        url:'/map/getProvinceForAccount',
                        async:false,
                        data:null,
                        type:'GET',
                        success:function (data) {
                            provinceData.features.forEach(function (item) {
                                var list = data.result;
                                var name = xdmap.strWrap(item.properties.name,3);
                                var zoneNumber = item.properties.id + '0000';
                                var text = website.getText(list, name, zoneNumber)[0];
                                var count = website.getText(list, name, zoneNumber)[1];
                                var center = null;
                                if (item.properties.id == '15') { //内蒙
                                    center = [13264576.140496347, 5523033.915773695];
                                }
                                else if (item.properties.id == '62') { //甘肃
                                    center = [10710967.899545176, 4896861.780061531];
                                }
                                else if (item.properties.id == '13') { //河北
                                    center = [12848147.210398706, 4627803.440497711];
                                }
                                else if (item.properties.id == '61') { //陕西
                                    center = [12119855.204897547, 4084794.7915598187];
                                } else {
                                    center = ol.proj.transform(item.properties.cp, 'EPSG:4326', 'EPSG:3857');
                                }

                                var feature = new ol.Feature({
                                    id: item.properties.id,
                                    geometry: new ol.geom.Circle(center, radius),
                                    text: text
                                });
                                feature.set('count', count, false);
                                feature.set('type', 'province', false);
                                features.push(feature);
                            });
                            source.addFeatures(features);
                        }
                    })
                })
                $("#district option").remove();
                $("#s2id_district span:first").html("行政区");
                var city = $("#city").val()
                $("#district").append("<option value='-1' >行政区</option>")
                if (city == '-1') {
                    return
                }
                $.ajax({
                    url: "/estate/districtList",
                    type: "POST",
                    data: { 'city': city },
                    success: function (result) {
                        for (var i = 0; i < result.districtList.length; i++) {
                            $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                        }
                    }
                });
            }
        });
        source.set('id', 'province');
        this.provinceSource = source;
        return source;
    },
    getCitySource: function (id) {
        var url = '../../assets/newMap/data/mapdata/city/' + id + '.json';
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                $.getJSON(url, function (cityData) {
                    var zoom = map.getView().getZoom();
                    var radius = 1e6 / Math.pow(2, zoom - 2);
                    var features = source.getFormat().readFeatures(cityData);
                    var newid = id + '0000';
                    $.ajax({
                        url: '/map/getCityForAccount',
                        async: true,
                        data: {
                            province: newid
                        },
                        type: 'POST',
                        success: function (data) {
                            var list = data.result;
                            features.forEach(function (item) {
                                var name = xdmap.strWrap(item.N.name,3);
                                var zoneNumber = item.N.id + '00';
                                var text = website.getText(list, name, zoneNumber)[0];
                                var count = website.getText(list, name, zoneNumber)[1];
                                var center = ol.proj.transform(item.N.cp, 'EPSG:4326', 'EPSG:3857');
                                var feature = new ol.Feature({
                                    id: item.N.id,
                                    name: name,
                                    text: text,
                                    geometry: new ol.geom.Circle(center, radius)
                                });
                                feature.set('count', count, false);
                                feature.set('type', 'city', false);
                                source.addFeature(feature);
                            })
                            source.addFeatures(features);
                        }
                    })

                })
            }
        });
        source.set('id', 'city');
        this.citySource = source;
        return source;
    },
    getCountySource: function (inputData) {
        var url = '../../assets/newMap/data/mapdata/county/' + inputData.city + '.json';
        var source = new ol.source.Vector({
            id: 'county',
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                $.getJSON(url, function (mapData) {
                    var zoom = map.getView().getZoom();
                    var radius = 1e6 / Math.pow(2, zoom -2);
                    var features = source.getFormat().readFeatures(mapData);
                    $.ajax({
                        url: '/map/getDistrictForAccount',
                        type: 'POST',
                        async: true,
                        data: {
                            city: inputData.city
                        },
                        success: function (data) {
                            var list = data.result;
                            features.forEach(function (item) {
                                var name = xdmap.strWrap(item.N.name, 3);
                                var zoneNumber = item.N.id;
                                var text = website.getText(list, name, zoneNumber)[0];
                                var count = website.getText(list, name, zoneNumber)[1];
                                var ext = item.getGeometry().getExtent();
                                var center = ol.extent.getCenter(ext);
                                var feature = new ol.Feature({
                                    id: item.N.id,
                                    name: name,
                                    text: text,
                                    geometry: new ol.geom.Circle(center, radius)
                                });
                                feature.set('count', count, false);
                                feature.set('type', 'county', false);
                                source.addFeature(feature);
                            })
                            source.addFeatures(features);
                        }
                    })
                })
                website.getArea();
            }
        });
        source.set('id', 'county');
        this.countySource = source;
        return source;
    },
    getRqSource: function (inputData) {
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                $.ajax({
                    url: '/map/getBankForAccount',
                    type: 'POST',
                    async: true,
                    data: {
                        district: inputData.district
                    },
                    success: function (data) {
                        var list = data.bankList;
                        var zoom = map.getView().getZoom();
                        var radius = 1e6 / Math.pow(2, zoom - 2.5);
                        list.forEach(function (item) {
                            var center = ol.proj.transform([item.x, item.y], 'EPSG:4326', 'EPSG:3857');
                            var text = xdmap.strWrap(item.name, 5);
                            var feature = new ol.Feature({
                                id: item.id,
                                name: item.name,
                                geometry: new ol.geom.Circle(center, radius),
                                text: text
                            });
                            feature.set('id', item.id, false);
                            feature.set('type', 'rq', false);
                            if (item.code) {
                                feature.set('level', item.code);
                            } else {
                                feature.set('level', "");
                            }
                            source.addFeature(feature);
                        })
                    }
                })
            }
        })
        source.set('id', 'rq', false);
        this.rqSource = source;
        return source;
    },
    getRqInfoSource: function () {
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                debugger;
                var resultFeature = null;
                if(website.clickFeature != null){
                    resultFeature = website.clickFeature;
                }else {
                    var ext = map.getView().calculateExtent();
                    var resultFeatures = website.rqSource.getFeaturesInExtent(ext);
                    var minDistance = 0;
                    resultFeatures.forEach(function (feature) {
                        var point = feature.getGeometry().getCenter();
                        var distance = new ol.Sphere(6378137).haversineDistance(point, website.mousePosition);
                        if (minDistance == 0) {
                            minDistance = distance;
                            resultFeature = feature;
                        } else {
                            if (distance < minDistance) {
                                minDistance = distance;
                                resultFeature = feature;
                            }
                        }
                    })
                }
                if (resultFeature == null) {
                    return;
                }
                $.ajax({
                    url:'/map/getBankForSourceId',
                    type:'POST',
                    async:true,
                    data: {
                        sourceId: resultFeature.N.id,
                        city:$('#city').val()
                    },
                    success:function (data) {
                        var list = data.resultList;
                        var name = resultFeature.N.name;
                        list.forEach(function (item) {
                            // var name = item.name;
                            var total = item.total;
                            var houseTotal = item.house;
                            var coordinates = new Array();
                            coordinates[0] = new Array();
                            var pathStrArr = item.coordinates;
                            var arrPath = pathStrArr.split(';');
                            arrPath.forEach(function (points) {
                                var point = points.split(',');
                                coordinates[0].push(point);
                            })
                            var feature = new ol.Feature({
                                geometry: new ol.geom.Polygon(coordinates),
                                text: name,
                            })
                            var style = new ol.style.Style({
                                stroke: new ol.style.Stroke({
                                    color: 'rgba(250,176,117,1)',
                                    width: 2
                                }),
                                fill:new ol.style.Fill({
                                    color: 'rgba(255,179,91,0.2)'
                                }),
                                text: new ol.style.Text({
                                    font: '16px',
                                    textAlign: 'center',
                                    rotateWithView: true,
                                    text: feature.get('text'),
                                    fill: new ol.style.Fill({
                                        color: 'rgba(0, 0, 0, 1)'
                                    })
                                })
                            });
                            feature.setStyle(style);
                            var ext = feature.getGeometry().getExtent();
                            var center = ol.extent.getCenter(ext);
                            source.addFeature(feature);
                            var div = website.createDiv(name,total,houseTotal);
                            var centerOverly = new ol.Overlay({
                                element: div,
                                position: center
                            })
                            map.addOverlay(centerOverly);
                            map.getView().setCenter(center)
                        })
                    }
                })
            }
        })
        source.set('id', 'rqInfo');
        this.rqInfoSource = source;
        return source;
    },
    setCircle: function (zoom) {
        if (this.vector.getSource() != null) {
            this.vector.getSource().forEachFeature(function (feature) {
                var geo = feature.getGeometry();
                if (geo.getType() == 'Circle') {
                    if (zoom < 14) {
                        geo.setRadius(1e6 / Math.pow(2, zoom - 2));
                    } else {
                        geo.setRadius(1e6 / Math.pow(2, zoom - 2.5));
                    }
                }
            })
        }
    },
    onResChange: function (e) {
        var id = website.vector.getSource().get('id');
        var zoom = map.getView().getZoom();
        if (zoom >= 5 && zoom < 7) {//省份
            if (id != 'province') {
                website.vector.setSource(website.provinceSource);
            }
        } else if (zoom >= 7 && zoom < 9) { //市
            if (website.citySource != null) {
                if (id != 'city') {
                    website.vector.setSource(website.citySource);
                }
            }
        } else if (zoom >= 9 && zoom < 14) { // 县
            if (website.countySource != null) {
                if (id != 'county') {
                    website.vector.setSource(website.countySource);
                }
            }
        } else if (zoom >= 14 && zoom < 16) { // 小区
            website.hiddenOverly();
            if (website.clickFeature != null) {
                website.clickFeature.setStyle(website.clickStyle)
                website.clickFeature = null;
            }
            if (website.rqSource != null) {
                website.vector.setSource(website.rqSource);
            } else {
                var inputData = website.getInputData('clusterMap');
                website.vector.setSource(website.getRqSource(inputData))
            }
        } else if (zoom >= 16) { // 小区详情
            if (!website.isFindClick) {
                if (id != 'rqInfo') {
                    map.getOverlays().clear();
                    website.vector.setSource(website.getRqInfoSource());
                }
            }else{
                website.isFindClick = false;
            }
        }
        website.setCircle(zoom);
    },
    onPointerMove: function (e) {
        var zoom = map.getView().getZoom();
        if(zoom >= 16) {
            return
        }
        var pixel = e.mapBrowserEvent.pixel;
        var features = [];
        map.forEachFeatureAtPixel(pixel, function (feature, layer) {
            if (layer != null) {
                if (layer.getVisible()) { // 当图层被隐藏之后,光标下该图层忽略
                    features.push(feature);
                }
            }
        });
        var len = features.length;
        var features_by_source;
        if (len == 1 && zoom >= 12) {
            var type = features[0].getGeometry().getType();
            var style = features[0].getStyle();
            if (type == 'Circle') {
                var text = features[0].getProperties().text;
                features[0].setStyle(website.getSelectedPropertyStyle(type, text));
            } else if (type == 'Point') {
                features[0].setStyle(style);
            } else {
                var featureArr = map.getLayers().getArray();
                var featureArr_len = featureArr.length;
                for (var j = 0; j < featureArr_len; j++) {
                    if (typeof featureArr[j].setStyle !== 'undefined') {
                        var source = featureArr[j].getSource();
                        features_by_source = source.getFeatures();

                        var feature_len = features_by_source.length;
                        for (var m = 0; m < feature_len; m++) {
                            if (typeof features_by_source[m].getProperties().text === 'undefined') {
                                text = 'none';
                            } else {
                                var text = features_by_source[m].getProperties().text
                            }
                            var type = features_by_source[m].getGeometry().getType();
                            var style = features_by_source[m].getStyle();
                            features_by_source[m].setStyle(website.getUnselectedPropertyStyle(type, text, style, features_by_source[m]));
                        }
                    }
                }
            }
        } else if (len == 2) {
            var type1 = features[0].getGeometry().getType();
            var type2 = features[1].getGeometry().getType();

            if (type1 == 'Circle' || type2 == 'Circle') {
                if (features[0].N.id == features[1].N.id) {
                    for (var i = 0; i < len; i++) {
                        var text = features[i].getProperties().text;
                        var type = features[i].getGeometry().getType();
                        features[i].setStyle(website.getSelectedPropertyStyle(type, text));
                    }
                }
            }
        } else {
            var featureArr = map.getLayers().getArray();
            var featureArr_len = featureArr.length;
            for (var j = 0; j < featureArr_len; j++) {
                if (typeof featureArr[j].setStyle !== 'undefined') {
                    var source = featureArr[j].getSource();
                    features_by_source = source.getFeatures();

                    var feature_len = features_by_source.length;
                    for (var m = 0; m < feature_len; m++) {
                        if (typeof features_by_source[m].getProperties().text === 'undefined') {
                            text = 'none';
                        } else {
                            var text = features_by_source[m].getProperties().text
                        }
                        var type = features_by_source[m].getGeometry().getType();
                        var style = features_by_source[m].getStyle();
                        features_by_source[m].setStyle(website.getUnselectedPropertyStyle(type, text, style, features_by_source[m]));
                    }
                }
            }
        }
    },
    onPointerClick: function (e) {
        var pixel = map.getEventPixel(e.originalEvent);
        var feature = map.forEachFeatureAtPixel(pixel, function (feature, layer) {
            return feature;
        });
        if (feature == null) {
            return;
        }
        var extent = feature.getGeometry().getExtent();
        var center = ol.extent.getCenter(extent);
        var type = feature.get('type');
        var id = feature.N.id;
        switch (type) {
            case 'province': {
                map.getView().setCenter(center);
                map.getView().setZoom(8);
                var style = new ol.style.Style({
                    stroke: new ol.style.Stroke({
                        color: 'rgba(1, 1, 1,0)',
                        width: 0
                    })
                })
                feature.setStyle(style)
                website.vector.setSource(website.getCitySource(id));
            }
                break;
            case 'city': {
                $("#city").val(id + '00');
                $('#select2-chosen-1').text(feature.N.name);
                map.getView().setCenter(center);
                map.getView().setZoom(12);
                var inputData = website.getInputData('clusterMap');
                inputData.level = '3';
                var style = new ol.style.Style({
                    stroke: new ol.style.Stroke({
                        color: 'rgba(1, 1, 1,0)',
                        width: 0
                    })
                })
                feature.setStyle(style)
                website.vector.setSource(website.getCountySource(inputData));
            }
                break;
            case 'county': {
                map.getView().setCenter(center);
                map.getView().setZoom(14);
                var inputData = website.getInputData('clusterMap');
                var style = new ol.style.Style({
                    stroke: new ol.style.Stroke({
                        color: 'rgba(1, 1, 1,0)',
                        width: 0
                    })
                })
                feature.setStyle(style)
                inputData.district = id;
                website.vector.setSource(website.getRqSource(inputData));
            }
                break;
            case 'rq': {
                var leveCode = feature.get('level')
                if(leveCode != '4') {
                    return;
                }
                website.clickFeature = feature;
                website.clickStyle = feature.getStyle();
                var style = new ol.style.Style({
                    stroke: new ol.style.Stroke({
                        color: 'rgba(1, 1, 1,0)',
                        width: 0
                    })
                })
                feature.setStyle(style)
                map.getView().setCenter(center);
                map.getView().setZoom(16);
            }
                break;
        }
    },
    getSelectedPropertyStyle: function (type, text) {
        var style = null;
        if (type == 'Circle') {
            style = new ol.style.Style({
                fill: new ol.style.Fill({
                    color: 'rgba(226, 74, 76, 1)',
                    opacity: '0.05'
                }),
                text: new ol.style.Text({
                    font: '10px',
                    textAlign: 'center',
                    rotateWithView: true,
                    text: text,
                    fill: new ol.style.Fill({
                        color: '#FFFFFF'
                    })
                })
            })
        }
        if (type == 'MultiPolygon' || type == 'Polygon') {
            style = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: 'green',
                    width: 2
                }),
                fill: new ol.style.Fill({
                    color: 'rgba(76, 160, 101, 0.5)'
                })
            })
        }
        return style;
    },
    getUnselectedPropertyStyle: function (type, text, Style, feat) {
        var style = null;
        if (type == 'Point') { // 如果是点, 不去设置他的样式
            style = Style;
        }
        if (type == 'Circle') {
            var size = 5;
            var id = website.vector.getSource().get('id')
            var size = feat.get('count');
            var color = null;

            if (size == null) {
                color = 'rgba(76, 160, 101, 0.9)';
            } else {
                color = website.getColorForId(id, size);
            }

            style = new ol.style.Style({
                fill: new ol.style.Fill({
                    color: color,
                    opacity: '0.05'
                }),
                text: new ol.style.Text({
                    font: '10px',
                    textAlign: 'center',
                    rotateWithView: true,
                    text: text,
                    fill: new ol.style.Fill({
                        color: 'rgba(255, 255, 255, 1)'
                    })
                })
            })
        }
        if (type == 'MultiPolygon' || type == 'Polygon') {
            style = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: 'rgba(55, 155, 205, 1)',
                    width: 1
                })
            })
        }
        return style;
    },
    getText: function (list, name, zoneNumber) {
        var result = new Array()
        list.forEach(function (item) {
            if (item.zone_number == zoneNumber) {
                result[0] = name + '\n' + item.count + '个';
                result[1] = item.count;
            }
        })
        if(result.length == 0) {
            result[0] = name + '\n' + '0个';
            result[1] = 0;
        }
        return result;
    },
    getCenter: function (id) {
        var cityId = id.substring(0, 2);
        var center = null;
        var url = '../../assets/newMap/data/mapdata/city/' + cityId + '.json';
        $.ajax({
            url: url,
            type: 'GET',
            async: false,
            success: function (data) {
                data.features.forEach(function (item) {
                    if (id == (item.properties.id + '00')) {
                        center = ol.proj.transform(item.properties.cp, 'EPSG:4326', 'EPSG:3857');
                        return;
                    }
                });
                if (center == null) {
                    center = ol.proj.transform(data.cp, 'EPSG:4326', 'EPSG:3857');
                }
            }
        })
        return center;
    },
    reset: function () {
        var inputData = this.getInputData('clusterMap');
        inputData.level = '3';
        this.vector.setSource(this.getCountySource(inputData));
        var center = this.getCenter(inputData.city);
        map.getView().setCenter(center);
        map.getView().setZoom(10);
    },
    setRqCenter:function (data) {
        var zoom = map.getView().getZoom();
        var center = ol.proj.transform([data.x, data.y], 'EPSG:4326', 'EPSG:3857');
        var feature = new ol.Feature({
            id: data.id,
            name: data.name,
            geometry: new ol.geom.Point(center),
        });
        website.clickFeature = feature;
        website.clickStyle = feature.getStyle();
        map.getView().setCenter(center);
        map.getOverlays().clear();
        website.vector.setSource(website.getRqInfoSource());
        website.isFindClick = true;
        map.getView().setZoom(16);
    },
    getInputData: function (currentMap) {
        var communityName = $("#search").val(),
            city = $('#city').val(),
            district = $('#district').val(),
            risk = $('#risk').val(),
            startDateStart = $('#startDateStart').val(),
            startDateEnd = $('#startDateEnd').val(),
            buildArea = $('#buildArea').val(),
            customCode = $('#customCode').val(),
            customValue = $('#customValue').val(),
            loansDuration = $('#loansDuration').val(),
            inputData = {
                communityName: communityName,
                city: city,
                district: district,
                risk: risk,
                startDateStart: startDateStart,
                startDateEnd: startDateEnd,
                buildArea: buildArea,
                loansDuration: loansDuration,
                currentMap: currentMap,
                customCode: customCode,
                customValue: customValue
            };
        return inputData;
    },
    hiddenOverly: function () {
        var eleOverlys = $('.ol-overlay-container.ol-selectable');
        for (var i = 0; i < eleOverlys.length; i++) {
            var div = eleOverlys[i];
            var dis = div.style.display;
            if (dis != 'none') {
                div.style.display = 'none';
            }
        }
    },
    showOverly: function () {
        var eleOverlys = $('.ol-overlay-container.ol-selectable');
        for (var i = 0; i < eleOverlys.length; i++) {
            var div = eleOverlys[i];
            var dis = div.style.display;
            if (dis != 'block') {
                div.style.display = 'block';
            }
        }
    },
    getArea: function () {
        $("#district option").remove();
        $("#s2id_district span:first").html("行政区");
        var city = $("#city").val()
        $("#district").append("<option value='-1' >行政区</option>")
        if (city == '-1') {
            return
        }
        $.ajax({
            url: "/estate/districtList",
            type: "POST",
            async: false,
            data: { 'city': city },
            success: function (result) {
                for (var i = 0; i < result.districtList.length; i++) {
                    $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                }
            }
        });
    },
    getColorForId: function (id, size) {
        var color = 'rgba(76, 160, 101, 0.9)';
        switch (id) {
            case 'province': {
                if (size > 15) {
                    color = "#26b095";
                } else if (size > 10) {
                    color = "#33c3a7"
                } else if (size > 1) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
            case 'city': {
                if (size > 15) {
                    color = "#26b095";
                } else if (size > 10) {
                    color = "#33c3a7"
                } else if (size > 1) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
            case 'county': {
                if (size > 15) {
                    color = "#26b095";
                } else if (size > 10) {
                    color = "#33c3a7"
                } else if (size > 0) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
            case 'rq': {
                if (size > 15) {
                    color = "#26b095";
                } else if (size > 10) {
                    color = "#33c3a7"
                } else if (size > 0) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
        }
        return color;
    },
    createDiv: function (name,total,houseTotal) {
        var div = this._div = document.createElement("div");
        var img = document.createElement('img');
        img.src = '/assets/accountLogo/zhoubian.png';
        div.style.position = "absolute";
        div.style.cursor = 'pointer';
        div.style.zIndex = '1';
        var message = document.createElement('div');
        message.style.position = 'absolute';
        message.style.border = '1px solid rgb(98, 203, 49)';
        message.style.background = '#fff';
        message.style.borderRadius = '6px';
        message.style.width = '230px';
        message.style.height = '60px';
        message.style.top = '-70px';
        message.style.left = '-98px';
        message.style.textAlign = 'center';
        var header = document.createElement('h5');
        header.innerHTML = name;
        header.style.fontWeight = 'bold';
        header.style.color = '#62cb31';
        message.appendChild(header);
        var body = document.createElement('p');
        body.innerHTML = '贷款总量:<strong> ' +total+ '</strong>&nbsp;&nbsp;&nbsp;总户数:<strong> '+houseTotal+'</strong>';
        message.appendChild(body);
        var sj = this._p = document.createElement("p");
        sj.style.position = "absolute";
        sj.style.width = 0;
        sj.style.height = 0;
        sj.style.borderLeft = "10px solid transparent";
        sj.style.borderRight = "10px solid transparent";
        sj.style.bottom = "-20px";
        sj.style.left = '105px';
        sj.style.borderTop = "10px solid #62cb31";
        message.appendChild(sj);
        div.appendChild(message);
        div.appendChild(img);
        // message.onclick = function () {
        //     var href = location.origin + '/estate/index?communityId=' + website.rqInfoId + '&city=' + $('#city').val();
        //     window.open(href);
        // };
        img.onclick = function () {
            $(this).siblings('div').toggle();
        };
        return div;
    },
}